<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysql_log')->create('log_medas_sub_balances', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('米大师扣费记录');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->integer('channel')->comment('渠道标识id')->unsigned()->default(0);
            $table->integer('user_id')->comment('账号id')->unsigned()->default(0);
            $table->integer('order_id')->comment('订单id')->unsigned()->default(0);
            $table->char('trade_no', 32)->comment('订单编号')->default('');
            $table->integer('amount')->comment('扣除米大师币数量')->unsigned()->default(0);
            $table->tinyInteger('is_test')->comment('是否测试 1是 0否')->unsigned()->default(1);
            $table->integer('balance')->comment('总余额')->unsigned()->default(0);
            $table->integer('present_balance')->comment('赠送余额')->unsigned()->default(0);
            $table->integer('sum_save')->comment('累计现金充值获得币数')->unsigned()->default(0);
            $table->integer('sum_present')->comment('累计赠送的游戏币数量')->unsigned()->default(0);
            $table->integer('sum_balance')->comment('累计获得的游戏币数量')->unsigned()->default(0);
            $table->integer('sum_cost')->comment('累计总消耗')->unsigned()->default(0);

            $table->index('create_time');
            $table->index('game_id');
            $table->index('channel');
            $table->index('user_id');
            $table->index('order_id');
            $table->index('trade_no');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysql_log')->dropIfExists('log_medas_sub_balances');
    }
};
